package cn.edu.swufe.surverpark.struts2.action;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.edu.swufe.surverpark.model.Page;
import cn.edu.swufe.surverpark.model.Survey;
import cn.edu.swufe.surverpark.struts2.service.SurveyService;

/**
 *@author 陈龙 E-mail:529914446@qq.com
 *@version创建时间:2015年4月30日下午8:07:46
 *类说明
 */
@Controller
@Scope("prototype")
public class PageAction extends BaseAction<Page> {

	/**
	 * 
	 */
	private Integer sid;
	private Integer pid;
	@Resource
	private SurveyService surveyService;
	private static final long serialVersionUID = -4720463992546129311L;
	
	public String toAddPage(){
		return "addPagePage";
	}

	public Integer getSid() {
		return sid;
	}

	public void setSid(Integer sid) {
		this.sid = sid;
	}
	public String saveOrUpdatePage(){
		Survey s = new Survey();
		s.setId(sid);
		model.setSurvey(s);
		surveyService.saveOrUpdatePage(model);
		
		return "designSurveyAction";
	}

	public Integer getPid() {
		return pid;
	}

	public void setPid(Integer pid) {
		this.pid = pid;
	}

	public String editPage(){
		this.model = surveyService.getPage(pid);
		return "editPagePage";
	}
	
	public String deletePage(){
		surveyService.deletePage(pid);
		return "designSurveyAction";
	}
}

